﻿@{
    ViewBag.Title = "";
    Layout = "~/Views/Shared/_Index.cshtml";
    int tripPreAlarmDay = CacheHelper.GetCache("TripPreAlarmDay").ToInt();
    int salerId = OperatorProvider.Provider.GetCurrent().Id;
}
@using Raffles.OA.Data
@using Raffles.OA.Utility
<link href="~/Content/plugin/bootstrap.daterangepicker/daterangepicker.min.css" rel="stylesheet" />
<link href="~/Content/sale/css/project.css" rel="stylesheet" />
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header" id="searchDiv">
                    <div class="col-md-2 col-xs-12">
                        <div class="input-group">
                            <div class="input-group-addon">关键字</div>
                            <input type="text" id="keyWord" col="KeyWord" class="form-control" placeholder="请输入关键字查询" />
                        </div>
                    </div>
                    <div class="col-md-3 col-xs-12">
                        <div class="input-group">
                            <div class="input-group-addon">出团日期</div>
                            <input type="hidden" id="departureDateStart" col="DepartureDateStart" />
                            <input type="hidden" id="departureDateEnd" col="DepartureDateEnd" />
                            <input type='text' class="form-control" placeholder="请选择日期" id="DepartureDate" />
                        </div>
                    </div>
                    <div class="col-md-3 col-xs-12">
                        <div class="input-group">
                            <div class="input-group-addon">项目状态</div>
                            <select id="status" col="Status" class="form-control">
                                <option value="">全部</option>
                            </select> 
                        </div>
                    </div>
                    <div class="col-md-3 col-xs-12">
                        <div class="input-group">
                            <div class="input-group-addon">销售人员</div>
                            <select id="salerId" col="SalerId" class="form-control">
                                <option value="">全部</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-md-1 col-xs-12 text-center pull-right">
                        <a id="btnSearch" authorize="yes" class="btn btn-primary btn-sm" onclick="searchGrid()"><i class="fa fa-search"></i> 查询</a>
                    </div>
                </div>
            </div>
            <div class="box box-info">
                <div class="box-body">
                    <div class="table-responsive">
                        <div class="btn-group-sm" id="toolbar" role="group">
                            <a id="btnAdd" authorize="yes" class="btn btn-success" onclick="showForm(true)"><i class="fa fa-plus"></i> 新增报价单</a>
                            <a id="btnEdit" authorize="yes" class="btn btn-info disabled" onclick="showForm(false)"><i class="fa fa-edit"></i> 编辑报价单</a>
                            <a id="btnDeleteSettlement" authorize="yes" class="btn btn-danger disabled" onclick="deleteSettlement()"><i class="fa fa-trash-o"></i> 撤销报价单</a>
                            <a id="btnCompleteSettlement" authorize="yes" class="btn btn-warning disabled" onclick="submitFinance()"><i class="fa fa-caret-square-o-right"></i> 提交财务</a>
                        </div>
                        <table id="gridTable" class="table table-hover text-nowrap" @*style="table-layout:fixed;"*@>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<script src="~/Content/plugin/bootstrap.daterangepicker/daterangepicker.min.js"></script>
<script src="/Content/plugin/bootstrap.datepicker/js/moment-with-locales.js"></script> 
<script type="text/javascript">

    var expandChildGridIndex = -1;
    $(function () {
        $("#status").frameSelect({
            data: frame.getJson(@Html.Raw(typeof(ProjectStatusEnum).EnumToDictionaryString())),
            default:[@((int)ProjectStatusEnum.DataIn)]
        });

        $("#salerId").frameSelect({
            url: "@Url.Action("GetSalerSelect", "Project",new { area = "Sale" })"
        });
        $('#departureDateStart').val(moment().startOf('year').format('YYYY-MM-DD'));
        $('#departureDateEnd').val(moment().endOf('year').format('YYYY-MM-DD'));
        $('#DepartureDate').daterangepicker({
            locale: {
                format: 'YYYY-MM-DD'
            },
            startDate: moment().startOf('year'),
            endDate: moment().endOf('year')
        }).on('apply.daterangepicker', function (ev, picker) {
            $('#departureDateStart').val(picker.startDate.format('YYYY-MM-DD'));
            $('#departureDateEnd').val(picker.endDate.format('YYYY-MM-DD'));
        }).on('cancel.daterangepicker', function (ev, picker) {
            // 重置选择器的值为默认值
            picker.setStartDate(moment().startOf('year'));
            picker.setEndDate(moment().endOf('year'));
            // 更新输入框的值
            $(this).val(picker.startDate.format('YYYY-MM-DD') + ' - ' + picker.endDate.format('YYYY-MM-DD'));
            $('#departureDateStart').val(moment().startOf('year').format('YYYY-MM-DD'));
            $('#departureDateEnd').val(moment().endOf('year').format('YYYY-MM-DD'));
        });
        initGrid();
        resetBootstrapTableView('gridTable', 109);
        $("#gridTable").on("check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table", function () {
            var rows = $("#gridTable").bootstrapTable("getSelections");
            if ($('#btnEdit')) {
                $('#btnEdit').toggleClass('disabled', rows.length != 1);
            }
            if ($('#btnDeleteSettlement')) {
                $('#btnDeleteSettlement').toggleClass('disabled', rows.length != 1);
            }
            if ($('#btnCompleteSettlement')) {
                $('#btnCompleteSettlement').toggleClass('disabled', rows.length != 1);
            }
        });
    });

    function initGrid() {
        $('#gridTable').frameTable({
            url: '@Url.Action("GetPageListJson", "Project")',
            detailView: true,
            singleSelect: true,
            sortName:'CreatedOn',
            sortOrder: 'desc',
            striped: false,
            showColumns: true,
            showRefresh: true,
            columns: [
                {
                    checkbox: true, visible: true,
                    formatter: function (value, row, index) {
                        //自己项目且状态数据录入中可编辑
                        if (row.SaleManagerId ==@salerId&& row.Status == @((int)ProjectStatusEnum.DataIn)) {
                            return {
                                disabled: false
                            };
                        }
                        else {
                            return {
                                disabled: true
                            };
                        }
                    }
                },
                {
                    field: 'Status', title: '项目状态', halign: "center", align: "center",
                    formatter: function (value, row, index) {
                        switch (value) {
                            case @((int)ProjectStatusEnum.DataIn):
                                return '<span class="label label-primary">@ProjectStatusEnum.DataIn.GetDescription()</span> ';
                            case @((int)ProjectStatusEnum.WaitMoney):
                                return '<span class="label label-info">@ProjectStatusEnum.WaitMoney.GetDescription()</span> ';
                            case @((int)ProjectStatusEnum.Done):
                                return '<span class="label label-warning">@ProjectStatusEnum.Done.GetDescription()</span> ';
                            case @((int)ProjectStatusEnum.Closed):
                                return '<span class="label label-success">@ProjectStatusEnum.Closed.GetDescription()</span> ';
                        }
                    }
                },
                {
                    field: 'DepartureDate', title: '行程日期', halign: "center", align: "center", sortable: true,
                    formatter: function (value, row, index) {
                        return "<span class='text-red text-bold font'>" + moment(row.DepartureDate).format('YYYY.MM.DD') + " - " + moment(row.ReturnDate).format('YYYY.MM.DD') +"</span>";
                    }
                },
                {
                    field: 'Name', title: '项目名称', halign: "center", align: "center",
                    formatter: function (value, row, index) {
                        return '<a class="text-blue text-bold" href="javascript:void(0);" onclick="showDetailForm(\'' + row.Id + '\')">' + value + '</a>'
                    }
                    //width: '200px',
                    //class: 'colStyle',
                    //formatter: function (value, row, index) {
                    //    if (value == null) {
                    //        value = "";
                    //    }
                    //    var span = document.createElement('span');
                    //    span.setAttribute('title', value);
                    //    span.innerHTML = value;
                    //    return '<a class="text-blue text-bold" href="javascript:void(0);" onclick="showDetailForm(\'' + row.Id + '\')">' + span.outerHTML + '</a>'
                    //}
                },
                {
                    field: 'Code', title: '项目信息', halign: "center", align: "left", visible: false,
                    formatter: function (value, row, index) {
                        return "合同编号：" + row.ContractCode + "<br />" +
                            "渠道来源：" + row.CustomerName;
                    }
                },
                {
                    field: '', title: '团组信息', halign: "center", align: "center",
                    formatter: function (value, row, index) {
                        return "<span class='text-bold text-info fontnumber'>" + row.AdultTotal + "</span>" + " 成人/" +
                            "<span class='text-bold text-red fontnumber'>" + (row.ChildTotal??0) + "</span>" + " 儿童/" +
                            "<span class='text-bold text-orange fontnumber'>" + (row.TeamLeader??0) + "</span>" + " 领队";
                    }
                },
                {
                    field: '', title: '汇率', halign: "center", align: "left", visible: false,
                    formatter: function (value, row, index) {
                        return "收客汇率：<span class='text-bold'>" + row.SettlementRate.toFixed(2) + "</span>" + "<br />" +
                            "到款汇率：<span class='text-bold'>" + row.PaymentRate.toFixed(2) + "</span>" + "<br />" +
                            "对公税率：<span class='text-bold'>" + row.TaxRate.toFixed(2) + "</span>";
                    }
                },
                {
                    field: '', title: '销售报价', halign: "left", align: "left",
                    formatter: function (value, row, index) {
                        return row.SettlementCurrency + "：<span class='text-bold text-green fontnumber underline'>" + frame.formatCurrency(row.SaleSGDAmountAfterTax, "USD") + "</span>" + "<br />" +
                            "RMB：<span class='text-bold text-red fontnumber underline'>" + frame.formatCurrency(row.SaleRMBAmountAfterTax, "CNY") + "</span>" + "</span>";
                    }
                },
                {
                    field: '', title: '项目成本(RMB)', halign: "left", align: "left",
                    formatter: function (value, row, index) {
                        return "<span class='text-bold text-green fontnumber underline'>" + frame.formatCurrency(row.CostRMBAmountAfterTax, "CNY") + "</span>";
                    }
                },
                {
                    field: '', title: '销售利润(RMB)', halign: "left", align: "left",
                    formatter: function (value, row, index) {
                        var moneyMake, moneyMakeFull = 0;
                        if (row.SaleRMBAmountAfterTax > 0) {
                            var moneyMakeFull = row.SaleRMBAmountAfterTax - row.CostRMBAmountAfterTax - row.TotalOperateCostAmount - row.SalerCommissionAmount;//销售净利=收入-成本-运营成本-提成
                            var moneyMake = row.SaleRMBAmountAfterTax - row.CostRMBAmountAfterTax;//销售毛利
                        }
                        return "净利：<span class='text-bold text-green fontnumber underline'>" + frame.formatCurrency(moneyMakeFull, "CNY") + "</span>" + "<br />" +
                            "毛利：<span class='text-bold text-red fontnumber underline'>" + frame.formatCurrency(moneyMake, "CNY") + "</span>";

                    }
                },
                {
                    field: '', title: '毛利润率(%)', halign: "center", align: "center",
                    formatter: function (value, row, index) {
                        var moneyMakeRate = 0;
                        if (row.SaleRMBAmountAfterTax > 0) {
                            var moneyMakeRate = (row.SaleRMBAmountAfterTax - row.CostRMBAmountAfterTax) / row.SaleRMBAmountAfterTax * 100;
                        }
                        return "<span class='text-bold text-green fontnumber underline'>" + (moneyMakeRate.toFixed(2)) + "%</span>" + "</span>";
                    }
                },
                {
                    field: 'SaleManagerName', title: '销售经理', halign: "center", align: "center",
                    formatter: function (value, row, index) {
                        if (!!row.InvolveCN) {
                            return value + "<br />" +
                                '<span class="label label-default fa fa-user-plus" style="padding:5px;"> ' + row.InvolveCN + '</span>';
                        }
                        else {
                            return value;
                        }

                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if ((row.Status == @((int)ProjectStatusEnum.DataIn)) && row.SaleManagerId ==@salerId) {

                        }
                        actions.push('<a id="btnPrint" authorize="yes" class="btn btn-success btn-xs" onclick="printForm(\'' + row.Id + '\')"><i class="fa fa-print"></i> 打印</a>');
                        return actions.join('');
                    }
                }
            ],
            queryParams: function (params) {
                var pagination = $('#gridTable').frameTable('getPagination', params);
                var queryString = $('#searchDiv').getWebControls(pagination);
                return queryString;
            },
            onExpandRow: function (index, row, $detail) {
                if (expandChildGridIndex >= 0 && expandChildGridIndex !== index) {
                    $("#gridTable").bootstrapTable('collapseRow', expandChildGridIndex);
                }
                expandChildGridIndex = index;//展开的table行
                initChildGrid(index, row, $detail);
            },
            onCollapseRow: function (index, row) {
                expandChildGridIndex = -1;//收起的table行
            },
            onLoadSuccess() {
                if (expandChildGridIndex >= 0) {
                    $("#gridTable").bootstrapTable('expandRow', expandChildGridIndex);
                }
            },
            rowStyle: function (row, index) {
                var classes = ['success', 'info', 'warning', 'danger'];
                var minusDay = moment(row.DepartureDate).diff(moment(), 'days');
                if (row.Status == @((int)ProjectStatusEnum.DataIn)&& minusDay >= 0 && minusDay <=@tripPreAlarmDay) {
                    return {
                        classes: 'danger'
                    };
                }
                return {};
            }
        });
    }

    function initChildGrid(index, tablerow, $detail) {
        var queryUrl = '@Url.Action("GetPageDetailListJson", "Project")' + "?projectId=" + tablerow.Id;
        var cur_table = $detail.html('<div class="detailview" style="border:1px solid #FF4500"><table></table></div>').find('table');
        $detail.css("padding-left", "45px");
        $(cur_table).frameTable({
            toolbar: '',
            url: queryUrl,
            striped: false,
            pagination: false,
            showToolbar: false,
            columns: [
                {
                    field: 'CountrySegmentCN', title: '行程分段', halign: "center", align: "center",
                    formatter: function (value, row, index) {
                        return '<span class="label label-info">' + value + '</span>';
                    }
                },
                {
                    field: '', title: '行程日期', halign: "center", align: "center",
                    formatter: function (value, row, index) {
                        return moment(row.DepartureDate).format('YYYY.MM.DD') + " - " + moment(row.ReturnDate).format('YYYY.MM.DD');
                    }
                },
                {
                    field: 'UpdatedOn', title: '结算货币', halign: "center", align: "center",
                    formatter: function (value, row, index) {
                        return row.SettlementCurrencyCN + "(" + row.SettlementCurrency + ")";
                    }
                },
                //{
                //    field: '', title: '汇率', halign: "center", align: "center",
                //    formatter: function (value, row, index) {
                //        return "结算汇率：<span class='text-bold'>" + row.SettlementRate.toFixed(2) + "</span> "+
                //            "付款汇率：<span class='text-bold'>" + row.PaymentRate.toFixed(2) + "</span> " +
                //            "地接税率：<span class='text-bold'>" + row.TaxRate.toFixed(2) + "</span>";
                //    }
                //},
                {
                    field: '', title: '销售报价(RMB)', halign: "center", align: "center",
                    formatter: function (value, row, index) {
                        return "<span class='text-bold text-green fontnumber underline'>" + frame.formatCurrency(row.SaleRMBAmountAfterTax, "CNY") + "</span>";
                    }
                },
                {
                    field: '', title: '项目成本(RMB)', halign: "center", align: "center",
                    formatter: function (value, row, index) {
                        return "<span class='text-bold text-green fontnumber underline'>" + frame.formatCurrency(row.CostRMBAmountAfterTax, "CNY") + "</span>";
                    }
                },
                {
                    field: '', title: '销售利润(RMB)', halign: "center", align: "center",
                    formatter: function (value, row, index) {
                        return "<span class='text-bold text-green fontnumber underline'>" + frame.formatCurrency(row.SaleRMBAmountAfterTax - row.CostRMBAmountAfterTax, "CNY") + "</span>";
                    }
                },
                {
                    field: '', title: '毛利润率(%)', halign: "center", align: "center",
                    formatter: function (value, row, index) {
                        var moneyMakeRate = 0;
                        if (row.SaleRMBAmountAfterTax > 0) {
                            var moneyMakeRate = (row.SaleRMBAmountAfterTax - row.CostRMBAmountAfterTax) / row.SaleRMBAmountAfterTax * 100;
                        }
                        return "<span class='text-bold text-green fontnumber underline'>" + (moneyMakeRate.toFixed(2)) + "%</span>" + "</span>";
                    }
                },
                {
                    field: 'PayStatus', title: '支付状态', halign: "center", align: "center",
                    formatter: function (value, row, index) {
                        switch (value) {
                            case @((int)ProjectCostPayEnum.NotPay):
                                return '<span class="label label-default">@ProjectCostPayEnum.NotPay.GetDescription()</span> ';
                            case @((int)ProjectCostPayEnum.PayAudit):
                                return '<span class="label label-primary">@ProjectCostPayEnum.PayAudit.GetDescription()</span> ';
                            case @((int)ProjectCostPayEnum.PayAuditPass):
                                return '<span class="label label-info">@ProjectCostPayEnum.PayAuditPass.GetDescription()</span> ';
                            case @((int)ProjectCostPayEnum.Paid):
                                return '<span class="label label-success">@ProjectCostPayEnum.Paid.GetDescription()</span> ';
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (tablerow.SaleManagerId ==@salerId) {
                            //数据录入状态下可编辑成本
                            if (tablerow.Status == @((int)ProjectStatusEnum.DataIn)) {
                                actions.push('<a href="javascript:void(0);" authorize="yes" id="btnEditDetail" class="btn btn-primary btn-xs" onclick="showSettlementForm(\'' + row.Id + '\',\'edit\')"><i class="fa fa-edit"></i> 编辑成本</a> ');
                            }
                            //等待收支状态下可申请支付
                            if (tablerow.Status == @((int)ProjectStatusEnum.WaitMoney)&& row.PayStatus ==@((int)ProjectCostPayEnum.NotPay)) {
                                actions.push('<a href="javascript:void(0);" authorize="yes" id="btnCostPayApply" class="btn btn-info btn-xs" onclick="costPayApply(\'' + row.Id + '\')"><i class="fa fa-dollar"></i> 申请支付</a> ');
                            }
                        }
                        actions.push('<a href="javascript:void(0);" class="btn btn-warning btn-xs" onclick="showSettlementForm(\'' + row.Id + '\',\'view\')"><i class="fa fa-eye"></i> 查看</a>');
                        return actions.join('');
                    }
                }
            ],
            onLoadSuccess: function (data) {
                $('.detailview .table').css('background-color', '#FAFAD2');
                $('.detailview .table> thead > tr > th').css('color', '#4169E1').css("font-style","italic");
                $('.detailview .table').removeClass('table-hover');
            }
        });
    }

    function searchGrid() {
        $('#gridTable').frameTable('search');
        resetButtonStatus();
    }

    function resetButtonStatus() {
        if ($('#btnEdit')) {
            $('#btnEdit').addClass('disabled');
        }
        if ($('#btnDeleteSettlement')) {
            $('#btnDeleteSettlement').addClass('disabled');
        }
        if ($('#btnCompleteSettlement')) {
            $('#btnCompleteSettlement').addClass('disabled');
        }
    }

    //客户结算单-详情
    function showDetailForm(id) {
        frame.openDialog({
            title: '客户报价单详情',
            content: '@Url.Content("/Sale/Project/QuotationForm")' + '?id=' + id + "&type=view",
            width: ($(window).width() - 20) + 'px',
            height: ($(window).height() - 20) + 'px',
            btn: null,
            success: function (layero, index) {
                $(window).resize(function () {
                    layer.style(index, {
                        top: '10px',
                        left: '10px',
                        right: '10px',
                        width: ($(window).width() - 20) + 'px',
                        height: ($(window).height() - 20) + 'px',
                    })
                });
            }
        });
    }

    //客户结算单-维护
    function showForm(isAdd) {
        var id = 0;
        if (!isAdd) {
            var selectedRow = $("#gridTable").bootstrapTable("getSelections");
            if (!frame.checkRowEdit(selectedRow)) {
                return;
            }
            else {
                id = selectedRow[0].Id;
            }
        }

        frame.openDialog({
            title: id > 0 ? "编辑客户报价单" : "新增客户报价单",
            content: '@Url.Content("/Sale/Project/QuotationForm")' + '?id=' + id,
            width: ($(window).width() - 20) + 'px',
            height: ($(window).height() - 20) + 'px',
            callback: function (index, layero) {
                var iframeWin = window[layero.find('iframe')[0]['name']];
                iframeWin.PageUI.saveForm(index);
            },
            success: function (layero, index) {
                $(window).resize(function () {
                    layer.style(index, {
                        top: '10px',
                        left: '10px',
                        right: '10px',
                        width: ($(window).width() - 20) + 'px',
                        height: ($(window).height() - 20) + 'px',
                    })
                });
            }
        });
    }

    //财务结算单
    function showSettlementForm(id, type) {
        frame.openDialog({
            title: '编辑成本结算单',
            content: '@Url.Content("/Sale/Project/FinanceSettlement")' + '?id=' + id + "&type=" + type,
            width: ($(window).width() - 20) + 'px',
            height: ($(window).height() - 20) + 'px',
            btn: type == 'view' ? null : ["保存", "关闭"],
            callback: function (index, layero) {
                var iframeWin = window[layero.find('iframe')[0]['name']];
                iframeWin.PageUI.saveForm(index);
            },
            success: function (layero, index) {
                $(window).resize(function () {
                    layer.style(index, {
                        top: '10px',
                        left: '10px',
                        right: '10px',
                        width: ($(window).width() - 20) + 'px',
                        height: ($(window).height() - 20) + 'px',
                    })
                });
            }
        });
    }

    //提交财务
    function submitFinance() {
        var id = 0;
        var selectedRow = $("#gridTable").bootstrapTable("getSelections");
        if (!frame.checkRowEdit(selectedRow)) {
            return;
        }
        else {
            id = selectedRow[0].Id;
        }
        frame.confirm("确定提交财务等待团费收支吗？", function () {
            frame.ajax({
                url: '@Url.Content("/Sale/Project/SubmitFinance")' + '?projectId=' + id,
                type: "post",
                success: function (obj) {
                    if (obj.success) {
                        frame.msgSuccess(obj.message);
                        searchGrid();
                    }
                    else {
                        frame.msgError(obj.message);
                    }
                }
            });
        });
    }

    //撤销结算
    function deleteSettlement() {
        var id = 0;
        var selectedRow = $("#gridTable").bootstrapTable("getSelections");
        if (!frame.checkRowEdit(selectedRow)) {
            return;
        }
        else {
            id = selectedRow[0].Id;
        }
        frame.confirm("确定撤销当前行程的报价单吗？", function () {
            frame.ajax({
                url: '@Url.Content("/Sale/Project/DeleteSettlement")' + '?projectId=' + id,
                type: "post",
                success: function (obj) {
                    if (obj.success) {
                        frame.msgSuccess(obj.message);
                        searchGrid();
                    }
                    else {
                        frame.msgError(obj.message);
                    }
                }
            });
        });
    }

    //申请支付
    function costPayApply(id) {
        frame.confirm("确定申请当前分段的成本支付吗？", function () {
            frame.ajax({
                url: '@Url.Content("/Sale/Project/ApplyCostPay")' + '?projectId=' + id,
                type: "post",
                success: function (obj) {
                    if (obj.success) {
                        frame.msgSuccess(obj.message);
                        searchGrid();
                    }
                    else {
                        frame.msgError(obj.message);
                    }
                }
            });
        });
    }

    //打印报价单
    function printForm(id) {
        frame.openDialog({
            title: "团队报价确认书",
            content: '@Url.Content("/Sale/Project/QuotationPrint")' + '?id=' + id + "&type=print",
            width: ($(window).width() - 20) + 'px',
            height: ($(window).height() - 20) + 'px',
            btn: ["打印", "关闭"],
            callback: function (index, layero) {
                var iframeWin = window[layero.find('iframe')[0]['name']];
                iframeWin.printQuotationForm(index);
            },
            success: function (layero, index) {
                $(window).resize(function () {
                    layer.style(index, {
                        top: '10px',
                        left: '10px',
                        right: '10px',
                        width: ($(window).width() - 20) + 'px',
                        height: ($(window).height() - 20) + 'px',
                    })
                });
            }
        });
    }
</script>